<template>
	<view class="container">
		<u-navbar placeholder title="我的银行卡" :autoBack="true"></u-navbar>
		<view class="pad-30">
			<view class="list-box">
				<u-swipe-action>
					<u-swipe-action-item class="mar-bottom-30" :options="options1" @click="hanldeRome"
						v-for="item in kftList">
						<view class="list radius14 pad-30">
							<view class="font-32 color-white">{{item.card_no}}</view>
							<view class="font-32 mar-top-30 color-white">{{getString(item.linked_acctno)}}</view>
						</view>
					</u-swipe-action-item>
				</u-swipe-action>
			</view>
			<view @click="hanldeAdd" class="addCard mar-top-30 font-28">+ 添加银行卡</view>
		</view>
	</view>
</template>

<script>
	// 接口地址
	import {
		backCardGetAll,
		unlinkBankCard,
	} from '@/config/api.js'
	import {
		llWallet
	} from '@/config/url.js'
	export default {
		data() {
			return {
				kftList: [],
				options1: [{
					text: '解绑'
				}]
			}
		},
		onShow() {
			this.getDataList();
		},
		methods: {
			// 解绑银行卡
			hanldeRome(e) {
				uni.showModal({
					title: '提醒',
					content: '你确定解绑吗',
					success: (res) => {
						if (res.confirm) {
							let data = {
								plat_id: 13,
								kft: {
									bind_id: this.kftList[e.index].id
								}
							}
							unlinkBankCard(data).then(res => {
								uni.showToast({
									title: res.msg
								})
								this.getDataList();
							})
						}
					}
				})
			},
			// 连连钱包绑卡
			hanldeAdd() {
				uni.navigateTo({
					url: '/pages/kft/bindAdd'
				})
			},
			// 字符串替换
			getString(text) {
				if (text) {
					return text.replace(/().*(.{4})/, "**** **** **** $2")
				}
			},
			// 获取银行卡
			getDataList() {
				backCardGetAll({
					plat_id: 13
				}).then(res => {
					this.kftList = res.data.kft
				})
			}

		}
	}
</script>

<style scoped lang="scss">
	.container {
		min-height: 100vh;

		::v-deep .u-navbar__content {
			background-image: url('../../static/image/my-bg.png');
			background-size: cover;
			background-repeat: no-repeat;
			background-color: #f5f5f5;
		}

		::v-deep .u-swipe-action-item__content {
			background: rgb(199, 198, 205);
		}

		::v-deep .u-swipe-action-item__right__button__wrapper {
			border-radius: 0 14rpx 14rpx 0 !important;

		}
	}

	.list {
		background: #259e4d;
		overflow: hidden;
	}

	.addCard {
		text-align: center;
		height: 94rpx;
		line-height: 94rpx;
		color: #000;
		background: #dedede;
		border-radius: 14rpx;
	}
</style>